/*
 * MP3_Beaney - The MP3 Tag Editor is a free ID3-Tag Editor
 * Copyright (C) 2012 Bernhard Teismann, André Seipelt, Steffen Gruschka, Imanuel Rohlfing
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
package model;

import java.io.File;

/**
 * Creates Exception Objects which are being thrown in MP3Management.
 * <p/>
 * @author Steffen Gruschka
 * @author Bernhard Teismann
 * @author André Seipelt
 * @author Imanuel Rohlfing
 * @version 1.0
 */
public class MP3Exception extends Exception {

    String exception;
    File file;
    String type;

    /**
     * Constructor. Creates an exception object.
     * <p/>
     * @param exception exception string
     * @param file file in which the exception occurred
     */
    public MP3Exception(String exception, File file){
        this.exception = exception;
        this.file = file;
        type = "Fehler!\n";
    }

    /**
     * Getter for the error string.
     * <p/>
     * @return a formatted string with the current error
     */
    public String get(){
        if (file == null){
            return type + " " + exception;
        }else{
            return type + " " + exception + " (" + file.getName() + ")";
        }
    }

    /**
     * Checks if current object is this exception.
     * <p/>
     * @param exception exception string
     * @return true if this.exception equals exception
     */
    public boolean equals(String exception){
        if (this.exception.equals(exception)){
            return true;
        }
        return false;
    }
}
